local sk__guhuo_active = fk.CreateSkill {

  name = "sk__guhuo_active",

  tags = {},

}



sk__guhuo_active:addEffect("active", {
  name = "sk__guhuo_active",
  expand_pile = function(self, player)
    return player:getTableMark("sk__guhuo_cards")
  end,
  card_num = 1,
  card_filter = function(self, player, to_select, selected)
    if #selected > 0 then return false end
    local mark = player:getTableMark("sk__guhuo_cards")
    if table.contains(mark, to_select) then
      local name = Fk:getCardById(to_select).name
      local card = Fk:cloneCard(name)
      card.skillName = "sk__guhuo"
      local target = Fk:currentRoom():getPlayerById(player:getMark("sk__guhuo_target"))
      return target:canUse(card, { bypass_times = true }) and not target:prohibitUse(card)
    end
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    if #selected_cards == 0 then return false end
    local card = Fk:cloneCard(Fk:getCardById(selected_cards[1]).name)
    card.skillName = "sk__guhuo"
    local target = Fk:currentRoom():getPlayerById(player:getMark("sk__guhuo_target"))
    if card.skill:getMinTargetNum(target) == 0 or #selected >= card.skill:getMaxTargetNum(target, card) then return false end
    return not target:isProhibited(to_select, card) and
        card.skill:modTargetFilter(target, to_select, selected, card)
  end,
  feasible = function(self, player, selected, selected_cards, card)
    if #selected_cards == 0 then return false end
    local card = Fk:cloneCard(Fk:getCardById(selected_cards[1]).name)
    card.skillName = "sk__guhuo"
    local target = Fk:currentRoom():getPlayerById(player:getMark("sk__guhuo_target"))
    return #selected >= card.skill:getMinTargetNum(target) and #selected <= card.skill:getMaxTargetNum(target, card)
  end,
})

return sk__guhuo_active
